home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1999-08-19 | 60.6 KB | 1,830 lines
/* * $Id: pand try tr) b.1 1999/08/19 14:16:33 lhecking Exp $ */ /* GNUPLOT - post.trm */ /*[ * Copyright 1990 - 1993, 1998 * * Permission to use, copy, and distribute this software and its * documentation for any purpose with or without fee is hereby granted, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to * distribute the complete modified source code. Modifications are to * be distributed as patches to the released version. Permission to * distribute binaries produced by compiling modified sources is granted, * provided you * 1. distribute the corresponding source modifications from the * released version in the form of a patch file along with the binaries, * 2. add special version identification to distinguish your version * in addition to the base release version number, * 3. provide your name and address as the primary contact for the * support of your modified version, and * 4. retain our contact information in regard to use of the base * software. * Permission to distribute the released version of the source code along * with corresponding source modifications in the form of a patch file is * granted with same provisions 2 through 4 for binary distributions. * * This software is provided "as is" without express or implied warranty * to the extent permitted by applicable law. ]*/ /* * This terminal driver supports: * postscript * * AUTHORS * Russell Lang * * modified 10/5/95 by drd - put in support for other postscript drivers * (enhpost, pslatex, ...) so they dont have to work quite so hard * * send your comments or suggestions to (info-gnuplot@dartmouth.edu). * * The 'postscript' driver produces landscape output 10" wide and 7" high. * To change font to Times-Roman and font size to 20pts use * 'set term postscript "Times-Roman" 20'. * To get a smaller (5" x 3.5") eps output use 'set term post eps' * and make only one plot per file. Font size for eps will be half * the specified size. * * Erik Luijten 30/5/97: added %%CreationDate, made %%DocumentFonts conform * to DSC, added version no. and patchl. to %%Creator */ #include "driver.h" #ifdef TERM_REGISTER register_term(post) #endif #ifdef TERM_PROTO TERM_PUBLIC void PS_options __PROTO((void)); TERM_PUBLIC void PS_common_init __PROTO((int encap, int portrait, int uses_fonts, unsigned int xoff, unsigned int yoff, unsigned int bb_xmin, unsigned int bb_ymin, unsigned int bb_xmax, unsigned int bb_ymax, char **dict)); TERM_PUBLIC void PS_init __PROTO((void)); TERM_PUBLIC void PS_graphics __PROTO((void)); TERM_PUBLIC void PS_text __PROTO((void)); TERM_PUBLIC void PS_reset __PROTO((void)); TERM_PUBLIC void PS_linetype __PROTO((int linetype)); TERM_PUBLIC void PS_move __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PS_vector __PROTO((unsigned int x, unsigned int y)); TERM_PUBLIC void PS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC void ENHPS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); TERM_PUBLIC int PS_text_angle __PROTO((int ang)); TERM_PUBLIC int PS_justify_text __PROTO((enum JUSTIFY mode)); TERM_PUBLIC void PS_point __PROTO((unsigned int x, unsigned int y, int number)); TERM_PUBLIC int PS_set_font __PROTO((char * font)); TERM_PUBLIC int ENHPS_set_font __PROTO((char * font)); TERM_PUBLIC void PS_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height)); TERM_PUBLIC void PS_linewidth __PROTO((double linewidth)); /* JFi [linewidth] */ TERM_PUBLIC void PS_pointsize __PROTO((double ptsize)); /* JFi [pointsize] */ #define PS_POINT_TYPES 8 #define PS_XOFF 50 /* page offset in pts */ #define PS_YOFF 50 #define PS_XMAX 7200 /* assumes landscape */ #define PS_YMAX 5040 #define PS_XLAST (PS_XMAX - 1) #define PS_YLAST (PS_YMAX - 1) #define PS_VTIC (PS_YMAX/80) #define PS_HTIC (PS_YMAX/80) #define PS_SC (10) /* scale is 1pt = 10 units */ #define PS_LW (0.5*PS_SC) /* linewidth = 0.5 pts */ #define PS_VCHAR (14*PS_SC) /* default is 14 point characters */ #define PS_HCHAR (14*PS_SC*6/10) #endif #ifndef TERM_PROTO_ONLY #ifdef TERM_BODY /* PostScript driver by Russell Lang, rjl@monu1.cc.monash.edu.au */ /* From version.c */ extern char version[]; extern char patchlevel[]; #define PS_FLUSH_PATH \ if (ps_path_count) { fprintf(gpoutfile, "stroke "); ps_path_count = 0; } static char *PS_RememberFont __PROTO((char *fname, int reencode)); static void ENHPS_put_text __PROTO((unsigned int x, unsigned int y, char *str)); static char *ENHPS_recurse __PROTO((char *p, TBOOLEAN brace, char *fontname, double fontsize, double base, TBOOLEAN widthflag, TBOOLEAN showflag)); static char ps_font[MAX_ID_LEN+1] = "Helvetica" ; /* name of font */ static int ps_fontsize = 14; /* size of font in pts */ /* for enhanced mode, we keep a separate font name and size, which * is restored to the default value on font of "" */ static char ps_enh_font[MAX_ID_LEN+1]; static int ps_enh_fontsize; static TBOOLEAN ps_portrait = FALSE; /* vertical page */ static TBOOLEAN ps_color = FALSE; static TBOOLEAN ps_solid = FALSE; /* use solid lines */ static TBOOLEAN ps_eps = FALSE; /* Is this for an eps file? */ /* Added by Robert Davis <davis@ecn.purdue.edu> */ static int ps_page=0; /* page count */ static int ps_path_count=0; /* count of lines in path */ static int ps_ang=0; /* text angle */ static enum JUSTIFY ps_justify=LEFT; /* text is flush left */ /* added by Matt Heffron <heffron@falstaff.css.beckman.com> */ static TBOOLEAN ps_duplex_state = FALSE; static TBOOLEAN ps_duplex_option = FALSE; static char GPFAR * GPFAR PS_header[] = { "/M {moveto} bind def\n", "/L {lineto} bind def\n", "/R {rmoveto} bind def\n", "/V {rlineto} bind def\n", "/vpt2 vpt 2 mul def\n", "/hpt2 hpt 2 mul def\n", /* flush left show */ "/Lshow { currentpoint stroke M\n", " 0 vshift R show } def\n", /* flush right show */ "/Rshow { currentpoint stroke M\n", " dup stringwidth pop neg vshift R show } def\n", /* centred show */ "/Cshow { currentpoint stroke M\n", " dup stringwidth pop -2 div vshift R show } def\n", /* set pointsize */ "/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def\n", " /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def\n", /* Dash or Color Line */ "/DL { Color {setrgbcolor Solid {pop []} if 0 setdash }\n", " {pop pop pop Solid {pop []} if 0 setdash} ifelse } def\n", /* Border Lines */ "/BL { stroke userlinewidth 2 mul setlinewidth } def\n", /* Axes Lines */ "/AL { stroke userlinewidth 2 div setlinewidth } def\n", /* set user defined linewidth */ "/UL { dup gnulinewidth mul /userlinewidth exch def\n", " 10 mul /udl exch def } def\n", /* Plot Lines */ "/PL { stroke userlinewidth setlinewidth } def\n", /* Line Types */ "/LTb { BL [] 0 0 0 DL } def\n", /* border */ "/LTa { AL [1 udl mul 2 udl mul] 0 setdash 0 0 0 setrgbcolor } def\n", /* axes */ "/LT0 { PL [] 1 0 0 DL } def\n", "/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def\n", "/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def\n", "/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def\n", "/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def\n", "/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def\n", "/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def\n", "/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def\n", "/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def\n", /* Point (Round) */ /* Matt Heffron make it round */ "/Pnt { stroke [] 0 setdash\n", " gsave 1 setlinecap M 0 0 V stroke grestore } def\n", /* Diamond */ "/Dia { stroke [] 0 setdash 2 copy vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath stroke\n", " Pnt } def\n", /* Plus */ "/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V\n", " currentpoint stroke M\n", " hpt neg vpt neg R hpt2 0 V stroke\n", " } def\n", /* Box */ "/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath stroke\n", " Pnt } def\n", /* Cross (X) */ "/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " hpt2 vpt2 neg V currentpoint stroke M\n", " hpt2 neg 0 R hpt2 vpt2 V stroke } def\n", /* Triangle Up*/ "/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath stroke\n", " Pnt } def\n", /* Star */ "/Star { 2 copy Pls Crs } def\n", /* div added filed box */ /* Filled Box */ "/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath fill } def\n", /* div added filled triangle */ /* Triangle Up, Filled */ "/TriUF { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath fill } def\n", /* Matt Heffron: added a few more types */ /* Triangle Down */ "/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath stroke\n", " Pnt } def\n", /* Triangle Down, Filled*/ "/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath fill} def\n", /* Diamond, Filled */ "/DiaF { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath fill } def\n", /* Pentagon */ "/Pent { stroke [] 0 setdash 2 copy gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath stroke grestore Pnt } def\n", /* Pentagon, Filled */ "/PentF { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath fill grestore } def\n", /* Circle */ "/Circle { stroke [] 0 setdash 2 copy\n", " hpt 0 360 arc stroke Pnt } def\n", /* Circle,Filled */ "/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def\n", /* 16 differently filled circles */ "/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450 arc } bind def\n", "/C1 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C2 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C3 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C4 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 180 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C5 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc\n", " 2 copy moveto\n", " 2 copy vpt 180 270 arc closepath fill\n", " vpt 0 360 arc } bind def\n", "/C6 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C7 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 270 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C8 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 270 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C9 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 270 450 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 90 180 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C11 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 180 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 270 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C12 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C13 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 0 90 arc closepath fill\n", " 2 copy moveto\n", " 2 copy vpt 180 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", "/C14 { BL [] 0 setdash 2 copy moveto\n", " 2 copy vpt 90 360 arc closepath fill\n", " vpt 0 360 arc } bind def\n", "/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill\n", " vpt 0 360 arc closepath } bind def\n", /* Auxiliary definitions for rectangles */ "/Rec { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto\n", " neg 0 rlineto closepath } bind def\n", "/Square { dup Rec } bind def\n", "/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def\n", /* 16 differently filled squares */ "/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def\n", "/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def\n", "/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n", "/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def\n", "/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n", "/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill\n", " exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def\n", "/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def\n", "/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill\n", " 2 copy vpt Square fill\n", " Bsquare } bind def\n", "/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def\n", "/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def\n", "/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill\n", " Bsquare } bind def\n", "/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill\n", " Bsquare } bind def\n", "/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def\n", "/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n", " 2 copy vpt Square fill Bsquare } bind def\n", "/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill\n", " 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def\n", "/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def\n", /* 16 different diamonds (actually just rotated squares) */ "/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def\n", "/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def\n", "/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def\n", "/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def\n", "/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def\n", "/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def\n", "/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def\n", "/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def\n", "/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def\n", "/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def\n", "/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def\n", "/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def\n", "/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def\n", "/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def\n", "/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def\n", "/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def\n", /* closed figures w/o the point in the middle (added by Dick Crawford) */ /* Diamond */ "/DiaE { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V closepath stroke } def\n", /* Box */ "/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V closepath stroke } def\n", /* Triangle Up*/ "/TriUE { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V closepath stroke } def\n", /* Triangle Down */ "/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V closepath stroke } def\n", /* Pentagon */ "/PentE { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " closepath stroke grestore } def\n", /* Circle */ "/CircE { stroke [] 0 setdash \n", " hpt 0 360 arc stroke } def\n", /* opaque closed figures w/o the point in the middle (added by Dick Crawford) */ "/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def\n", /* Diamond */ "/DiaW { stroke [] 0 setdash vpt add M\n", " hpt neg vpt neg V hpt vpt neg V\n", " hpt vpt V hpt neg vpt V Opaque stroke } def\n", /* Box */ "/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M\n", " 0 vpt2 neg V hpt2 0 V 0 vpt2 V\n", " hpt2 neg 0 V Opaque stroke } def\n", /* Triangle Up*/ "/TriUW { stroke [] 0 setdash vpt 1.12 mul add M\n", " hpt neg vpt -1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt 1.62 mul V Opaque stroke } def\n", /* Triangle Down */ "/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M\n", " hpt neg vpt 1.62 mul V\n", " hpt 2 mul 0 V\n", " hpt neg vpt -1.62 mul V Opaque stroke } def\n", /* Pentagon */ "/PentW { stroke [] 0 setdash gsave\n", " translate 0 hpt M 4 {72 rotate 0 hpt L} repeat\n", " Opaque stroke grestore } def\n", /* Circle */ "/CircW { stroke [] 0 setdash \n", " hpt 0 360 arc Opaque stroke } def\n", /* filled box : usage x1 y1 x2 y2 BoxFill */ "/BoxFill { gsave Rec 1 setgray fill grestore } def\n", NULL }; static char GPFAR * GPFAR ENHPS_header[] = { /* For MFshow and MFwidth the tos is an array with the string and font info: */ /* [<fontname (a string)> <fontsize> <vertical offset> <width significant?> <printed?> <text string>] */ "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n", " [ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n", " {show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n", " {2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n", "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n", " 5 get stringwidth pop add}\n", " {pop} ifelse} forall} bind def\n", /* flush left show */ "/MLshow { currentpoint stroke M\n", " 0 exch R MFshow } bind def\n", /* flush right show */ "/MRshow { currentpoint stroke M\n", " exch dup MFwidth neg 3 -1 roll R MFshow } def\n", /* centred show */ "/MCshow { currentpoint stroke M\n", " exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n", NULL }; /* added to enhpost by Matt Heffron <heffron@falstaff.css.beckman.com> */ /* moved to post.trm by drd */ static struct PS_FontName { char *name; struct PS_FontName *next; } *PS_DocFonts = NULL; /* given a font, look in store to see if it is there already * if so, return NULL. If not, reencode it if allowed to, otherwise * return an appropriate re-encode string */ TERM_PUBLIC char *PS_RememberFont(fname, can_reencode) char *fname; int can_reencode; { struct PS_FontName *fnp; char *recode = NULL; for (fnp=PS_DocFonts; fnp ; fnp = fnp->next) if (strcmp(fnp->name, fname)==0) return NULL; /* we did not find the name */ fnp = (struct PS_FontName *)gp_alloc(sizeof(struct PS_FontName), "PostScript Font record"); fnp->name = gp_alloc(1+strlen(fname), "PostScript Font name"); strcpy(fnp->name, fname); fnp->next = PS_DocFonts; PS_DocFonts = fnp; switch(encoding) { case ENCODING_ISO_8859_1: recode = "reencodeISO def\n"; break; case ENCODING_CP_437: recode = "reencodeCP437 def\n"; break; case ENCODING_CP_850 : recode = "reencodeCP850 def\n"; break; } if (can_reencode && recode) { fprintf(gpoutfile,"/%s %s",fname, recode); return NULL; } else return recode; } static int PS_pen_x, PS_pen_y; static int PS_taken; static int PS_linetype_last; static TBOOLEAN PS_relative_ok; TERM_PUBLIC void PS_options() { if (!END_OF_COMMAND) { if (almost_equals(c_token,"p$ortrait")) { ps_portrait=TRUE; ps_eps=FALSE; c_token++; } else if (almost_equals(c_token,"l$andscape")) { ps_portrait=FALSE; ps_eps=FALSE; c_token++; } else if (almost_equals(c_token,"ep$sf")) { ps_portrait=TRUE; ps_eps = TRUE; c_token++; } else if (almost_equals(c_token,"d$efault")) { ps_portrait=FALSE; ps_eps=FALSE; ps_color=FALSE; ps_solid=FALSE; ps_duplex_option=FALSE; strcpy(ps_font,"Helvetica"); ps_fontsize = 14; term->v_char = (unsigned int)(ps_fontsize*PS_SC); term->h_char = (unsigned int)(ps_fontsize*PS_SC*6/10); term->put_text = PS_put_text; c_token++; } } if (almost_equals(c_token, "enh$anced")) { term->put_text = ENHPS_put_text; term->set_font = ENHPS_set_font; ++c_token; } else if (almost_equals(c_token, "noenh$anced")) { term->put_text = PS_put_text; term->set_font = PS_set_font; ++c_token; } if (!END_OF_COMMAND) { if (almost_equals(c_token,"m$onochrome")) { ps_color=FALSE; c_token++; } else if (almost_equals(c_token,"c$olor") || almost_equals(c_token,"c$olour")) { ps_color=TRUE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token,"so$lid")) { ps_solid=TRUE; c_token++; } else if (almost_equals(c_token,"da$shed")) { ps_solid=FALSE; c_token++; } } if (!END_OF_COMMAND) { if (almost_equals(c_token,"si$mplex")) { ps_duplex_state = FALSE; ps_duplex_option = TRUE; c_token++; } else if (almost_equals(c_token,"du$plex")) { ps_duplex_state = TRUE; ps_duplex_option = TRUE; c_token++; } else if (almost_equals(c_token,"defaultp$lex")) { ps_duplex_option = FALSE; c_token++; } } if (!END_OF_COMMAND && isstring(c_token)) { quote_str(ps_font,c_token, MAX_ID_LEN); c_token++; } if (!END_OF_COMMAND) { /* We have font size specified */ struct value a; ps_fontsize = (int)real(const_express(&a)); term->v_char = (unsigned int)(ps_fontsize*PS_SC); term->h_char = (unsigned int)(ps_fontsize*PS_SC*6/10); } sprintf(default_font,"%s,%d",ps_font,ps_fontsize); /* default_font holds the font and size set at 'set term' */ /* Entry font added by DJL */ sprintf(term_options,"%s %senhanced %s %s %s \"%s\" %d", ps_eps ? "eps" : (ps_portrait ? "portrait" : "landscape"), term->put_text == ENHPS_put_text ? "" : "no", ps_color ? "color" : "monochrome", ps_solid ? "solid" : "dashed", ps_duplex_option ? (ps_duplex_state ? "duplex" : "simplex") : "defaultplex", ps_font,ps_fontsize); } /* store settings passed to common_init() for use in PS_graphics() * ps_eps, ps_portrait, etc are reserved for storing the term options */ static int ps_common_encap; static int ps_common_portrait; static int ps_common_uses_fonts; static unsigned int ps_common_xoff, ps_common_yoff; TERM_PUBLIC void PS_common_init(encap, portrait, uses_fonts, xoff, yoff, bb_xmin, bb_ymin, bb_xmax, bb_ymax, dict) int encap; /* encapsulated or not - 1 for pslatex */ int portrait; /* 1 for pslatex */ int uses_fonts; /* 0 for ps(la)tex */ unsigned int xoff, yoff; /* how much to translate by */ unsigned int bb_xmin, bb_ymin, bb_xmax, bb_ymax; /* bounding box */ char **dict; /* extra entries for the dictionary */ { static char GPFAR psi1[] = "%%%%Creator: gnuplot %s patchlevel %s\n\ %%%%CreationDate: %s\ %%%%DocumentFonts: %s\n"; static char GPFAR psi2[] = "%%%%EndComments\n\ /gnudict 256 dict def\ngnudict begin\n\ /Color %s def\n\ /Solid %s def\n\ /gnulinewidth %.3f def\n\ /userlinewidth gnulinewidth def\n\ /vshift %d def\n\ /dl {%d mul} def\n\ /hpt_ %.1f def\n\ /vpt_ %.1f def\n\ /hpt hpt_ def\n\ /vpt vpt_ def\n"; static char GPFAR * GPFAR PS_iso_8859_1_encoding[] = { "/reencodeISO {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "currentdict /CharStrings known {\n", "\tCharStrings /Idieresis known {\n", "\t\t/Encoding ISOLatin1Encoding def } if\n} if\n", "currentdict end definefont\n", "} def\n", "/ISOLatin1Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n", "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n", "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n", "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n", "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n", "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n", "/guillemotright/onequarter/onehalf/threequarters/questiondown\n", "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n", "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n", "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n", "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n", "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n", "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n", "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n", "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n", "/yacute/thorn/ydieresis\n", "] def\n", NULL }; /* encoding for code page 437 */ /* */ /* version 1.0: - Mainly letters are mapped. The following positions */ /* (JFi) are left blank (undefined): */ /* -- first 32 positions, */ /* -- frame characters, */ /* -- greek characters, */ /* -- some more special characters. */ /* */ /* version 1.1: - added some more special characters */ /* */ static char GPFAR * GPFAR PS_cp_437_encoding[] = { "/reencodeCP437 {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "currentdict /CharStrings known {\n", "\tCharStrings /Idieresis known {\n", "\t\t/Encoding CP437Encoding def } if\n} if\n", "currentdict end definefont\n", "} def\n", "/CP437Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef\n", "/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla\n", "/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring\n", "/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave\n", "/ydieresis/Odieresis/Udieresis/cent/sterling/yen/.notdef/florin\n", "/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine\n", "/questiondown/.notdef/logicalnot/onehalf/onequarter/exclamdown/guillemotleft/guillemotright\n", "/space/space/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/germandbls/.notdef/.notdef/.notdef/.notdef/mu/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/infinity/.notdef/.notdef/.notdef\n", "/.notdef/plusminus/greaterequal/lessequal/.notdef/.notdef/divide/.notdef\n", "/degree/bullet/periodcentered/.notdef/nsuperior/twosuperior/.notdef\n", "] def\n", NULL }; /* encoding for code page 850 */ /* */ /* version 1.0: - Mainly letters are mapped. The following positions */ /* (JFi) are left blank (undefined): */ /* -- first 32 positions, */ /* -- frame characters, */ /* -- a few special characters. */ /* */ static char GPFAR * GPFAR PS_cp_850_encoding[] = { "/reencodeCP850 {\n", "dup dup findfont dup length dict begin\n", "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n", "currentdict /CharStrings known {\n", "\tCharStrings /Idieresis known {\n", "\t\t/Encoding CP850Encoding def } if\n} if\n", "currentdict end definefont\n", "} def\n", "/CP850Encoding [\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n", "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n", "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n", "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n", "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n", "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n", "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n", "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef\n", "/Ccedilla/udieresis/eacute/acircumflex/adieresis/agrave/aring/ccedilla\n", "/ecircumflex/edieresis/egrave/idieresis/icircumflex/igrave/Adieresis/Aring\n", "/Eacute/ae/AE/ocircumflex/odieresis/ograve/ucircumflex/ugrave\n", "/ydieresis/Odieresis/Udieresis/oslash/sterling/Oslash/multiply/florin\n", "/aacute/iacute/oacute/uacute/ntilde/Ntilde/ordfeminine/ordmasculine\n", "/questiondown/registered/logicalnot/onehalf/onequarter/exclamdown/guillemotleft/guillemotright\n", "/space/space/.notdef/.notdef/.notdef/Aacute/Acircumflex/Agrave\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/cent/yen/.notdef\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/atilde/Atilde\n", "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/currency\n", "/eth/Eth/Ecircumflex/Edieresis/Egrave/dotlessi/Iacute/Icircumflex\n", "/Idieresis/.notdef/.notdef/.notdef/.notdef/brokenbar/Igrave/.notdef\n", "/Oacute/germandbls/Ocircumflex/Ograve/otilde/Otilde/mu/thorn\n", "/Thorn/Uacute/Ucircumflex/Ugrave/yacute/Yacute/macron/acute\n", "/hyphen/plusminus/equal/threequarters/paragraph/section/divide/.notdef\n", "/degree/.notdef/periodcentered/onesuperior/threesuperior/twosuperior/.notdef\n", "] def\n", NULL }; struct termentry *t = term; int i; time_t now; ps_common_encap = encap; /* store for later */ ps_common_portrait = portrait; /* store for later */ ps_common_uses_fonts = uses_fonts; ps_common_xoff = xoff; ps_common_yoff